package com.tanhua.manage.interceptor;

import com.tanhua.manage.domain.Admin;
import org.checkerframework.checker.units.qual.A;


/**
 * 通过ThreadLocal对象，存储用户的数据
 * 1、声明ThreadLocal对象
 * 2、向当前线程存储数据：threadLocal.set();
 * 3、从当前线程获取数据：threadLocal.get();
 */
public class AdminHolder {

    private static ThreadLocal<Admin> threadLocal = new ThreadLocal<Admin>();


    public static void set(Admin admin){
        threadLocal.set(admin);
    }

    public static Admin get(){
        return  threadLocal.get();
    }

    public static long getAdminId(){
        return get().getId();
    }
}
